package vcp.gui.panels.networkmanager;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JPanel;

import vcp.gui.components.VCPPanel;
import vcp.gui.components.VCPScrollTable;

import java.awt.BorderLayout;

import javax.swing.JLabel;
import javax.swing.JComboBox;

import com.toedter.calendar.JMonthChooser;
import com.toedter.calendar.JYearChooser;
import com.toedter.calendar.JCalendar;
import com.toedter.calendar.JDateChooser;

import javax.swing.JButton;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 * Monthly reports widget
 *
 */
public class PnlMonthlyReports extends JPanel {
	 private VCPPanel pnlReportTab;
	 private VCPPanel pnlGraphTab;
	 private JComboBox comboLot;
	 private JDateChooser dateChooser;
	 private VCPPanel pnlTableTab;
	 private JButton btnShow;
	 private VCPPanel pnlVioTab;
	 private VCPScrollTable reportsTable;
	 private DefaultTableModel dtm;
	 private Object[] gscale; 
	
	
	
	/**
	 * Create the panel.
	 */
	public PnlMonthlyReports() {
      setLayout(new GridLayout(2,1));      
      pnlReportTab = new VCPPanel();
      pnlReportTab.setBorder(new TitledBorder(null, "Monthly reports", TitledBorder.LEADING, TitledBorder.TOP, null, null));
      pnlReportTab.setLayout(null);

      pnlGraphTab = new VCPPanel();
      pnlTableTab = new VCPPanel();
      pnlVioTab = new VCPPanel();
      
      reportsTable = getReportsTable();
      pnlVioTab.setLayout(new GridLayout(1,2));
      
      pnlGraphTab.setLayout(new BorderLayout(0, 0));        
      
      pnlTableTab.setLayout(new BorderLayout(0, 0));
      
      
      JLabel lbllot = new JLabel("#Lot");
      lbllot.setBounds(12, 31, 56, 16);
      pnlReportTab.add(lbllot);
      
      comboLot = new JComboBox(new Object[]{1,2,3,4,5,6});
      comboLot.setBounds(61, 28, 34, 22);
      pnlReportTab.add(comboLot);
      
      dateChooser = new JDateChooser();
      dateChooser.setBounds(147, 28, 100, 22);
      pnlReportTab.add(dateChooser);
      
      JLabel lblDate = new JLabel("Date");
      lblDate.setBounds(107, 31, 56, 16);
      pnlReportTab.add(lblDate);
      
      btnShow = new JButton("show");
      btnShow.setBounds(259, 27, 97, 25);
      pnlReportTab.add(btnShow);

      pnlVioTab.add(pnlTableTab);
      pnlVioTab.add(pnlGraphTab);
      add(pnlReportTab);    
      add(pnlVioTab);      
	}
	
	public Object[] getGscale() {
		return gscale;
	}
	public void setGscale(Object[] gscale) {
		this.gscale = gscale;
	}
	public DefaultTableModel getDtm() {
		return dtm;
	}
	public void setDtm(DefaultTableModel dtm) {
		this.dtm = dtm;
	}
	public void setReportsTable(VCPScrollTable reportsTable) {
		this.reportsTable = reportsTable;
	}
	
	public VCPPanel getPnlTableTab() {
		return pnlTableTab;
	}
	public void setPnlTableTab(VCPPanel pnlTableTab) {
		this.pnlTableTab = pnlTableTab;
	}
	public VCPPanel getPnlReportTab() {
		return pnlReportTab;
	}
	public void setPnlReportTab(VCPPanel pnlReportTab) {
		this.pnlReportTab = pnlReportTab;
	}
	public VCPPanel getPnlGraphTab() {
		return pnlGraphTab;
	}
	public void setPnlGraphTab(VCPPanel pnlGraphTab) {
		this.pnlGraphTab = pnlGraphTab;
	}
	public JComboBox getComboLot() {
		return comboLot;
	}
	public void setComboLot(JComboBox comboLot) {
		this.comboLot = comboLot;
	}
	public JDateChooser getDateChooser() {
		return dateChooser;
	}
	public void setDateChooser(JDateChooser dateChooser) {
		this.dateChooser = dateChooser;
	}
	public JButton getBtnShow() {
		return btnShow;
	}
	public void setBtnShow(JButton btnShow) {
		this.btnShow = btnShow;
	}
	
	/**
	 * 
	 * @return vcp scroll table
	 */
	public VCPScrollTable getReportsTable() {
		if(reportsTable==null){
			
		   String[] header = { "Start week", "Type", "Average",
			            "Median", "Deviation"};
			
		   DefaultTableModel dtm = new DefaultTableModel(null, header) {
	    		private static final long serialVersionUID = 1L;
	    		@Override
	            public Class<?> getColumnClass(int col) {
	                return getValueAt(0, col).getClass();
	            }
	    	
	            public boolean isCellEditable(int row, int column){  
	            	return false; 
	            }       
	        };			
	        reportsTable = new VCPScrollTable(10,dtm);

		}
		return reportsTable;
	}
}
